//
//  HHSinglePickerView.h
//  XZParent
//
//  Created by chun.chen on 2018/10/18.
//  Copyright © 2018 Zhihan. All rights reserved.
//  单个选择器

#import <UIKit/UIKit.h>

NS_ASSUME_NONNULL_BEGIN

///////// 选择类型对象
@interface HHOptionsObject : NSObject <NSCoding>
/// 显示的文本
@property (nonatomic, strong) NSString *displaytext;
/// 对应的value
@property (nonatomic, strong, nullable) id formValue;

+(HHOptionsObject *)optionsObjectWithValue:(id _Nullable)value displayText:(NSString *)displayText;

@end

@interface HHSinglePickerView : UIView
/// 行高，默认30
@property (nonatomic, assign) CGFloat rowHeight;
/// 数据源
@property (nonatomic, strong, nullable) NSArray<HHOptionsObject *> *dataArr;
/// 上次选择的选项，formValue和displaytext一致即认为是同一个
@property (nonatomic, strong, nullable) HHOptionsObject *lastOptionsObject;
/// 确定按钮回调
@property (nonatomic, copy, nullable) void(^doneBlock)(HHOptionsObject *optionsObject);
/// 确定按钮
@property (nonatomic, strong, readonly) UIButton *doneButton;
/// 取消按钮
@property (nonatomic, strong, readonly) UIButton *cancelButton;
/// pickerView
@property (nonatomic, strong, readonly) UIPickerView *pickerView;

//MARK: - 显示
/**
快捷初始化选择器

@param view 将要显示的view，默认KeyWindow
@param dataArr 数据<HHOptionsObject>
@param completion 回调
*/
+ (instancetype )zh_pickerInView:(UIView *_Nullable)view withData:(NSArray<HHOptionsObject *>*)dataArr completion:(void(^_Nullable)(HHOptionsObject *optionsObject))completion;
/**
 快捷显示选择器

 @param view 将要显示的view，默认KeyWindow
 @param dataArr 数据<HHOptionsObject>
 @param completion 回调
 */
+ (instancetype )zh_showPickerInView:(UIView *_Nullable)view withData:(NSArray<HHOptionsObject *>*)dataArr completion:(void(^_Nullable)(HHOptionsObject *optionsObject))completion;

/// 显示选择器
- (void)showAnimtion;
///隐藏选择器
- (void)hideAnimation;

@end



NS_ASSUME_NONNULL_END
